package com.yy.controller;

import com.yy.param.FormContentParam;
import com.yy.param.FormHeadParam;
import com.yy.param.FormInfoParam;
import com.yy.util.ValidList;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * @author lyy
 * @date 2021/12/09
 */
@RestController
@RequestMapping("/form")
@Validated
public class FormController {

    @PostMapping("/head/save")
    public String saveHead(@RequestBody @Valid @NotEmpty(message = "参数不能为空") List<FormHeadParam> paramList){
        return paramList.toString();
    }

    @PostMapping("content/save")
    public String saveContent(@RequestBody @Validated ValidList<FormContentParam> paramList){
        return paramList.toString();
    }

    @PostMapping("/save")
    public String save(@RequestBody @Validated FormInfoParam param){
        return param.toString();
    }
}
